home *** CD-ROM | disk | FTP | other *** search
- #
- # msgcat.test
- #
- # Tests for the XPG/3 message catalog commands.
- #---------------------------------------------------------------------------
- # Copyright 1992 Karl Lehenbauer and Mark Diekhans.
- #
- # Permission to use, copy, modify, and distribute this software and its
- # documentation for any purpose and without fee is hereby granted, provided
- # that the above copyright notice appear in all copies. Karl Lehenbauer and
- # Mark Diekhans make no representations about the suitability of this
- # software for any purpose. It is provided "as is" without express or
- # implied warranty.
- #------------------------------------------------------------------------------
- # $Id: msgcat.test,v 2.0 1992/10/16 04:50:04 markd Rel $
- #------------------------------------------------------------------------------
-
- if {[info procs test] != "test"} then {source testlib.tcl}
-
- #
- # This only tests default strings, since its difficult to setup and rely on
- # a message catalog being present. This will work on systems without message
- # catalogs, as the stubs return default strings.
- #
-
- test message-cat-1.1 {catopen tests} {
- set msgcat [catopen "FOOBAZWAP"]
- catclose $msgcat
- crange $msgcat 0 5
- } {msgcat}
-
-
- test message-cat-1.2 {catopen tests} {
- set msgcat [catopen -nofail "FOOBAZWAP"]
- catclose $msgcat
- crange $msgcat 0 5
- } {msgcat}
-
-
- test message-cat-1.3 {catopen tests} {
- list [catch {catopen -fail "FOOBAZWAP"} msg] $msg
- case $msg {
- {"open of message catalog failed"} {concat "OK"}
- {"the message catalog facility is not available, default string is always returned"} {concat "OK"}
- default {concat "BAD"}
- }
- } {OK}
-
- test message-cat-2.1 {catclose tests} {
- set msgcat [catopen "FOOBAZWAP"]
- catclose $msgcat
- list [catch {catgets $msgcat} msg] $msg
- } {1 {catgets catHandle setnum msgnum defaultstr}}
-
-
- test message-cat-2.2 {catclose tests} {
- set msgcat [catopen "FOOBAZWAP"]
- catch {catclose $msgcat}
- } {0}
-
- test message-cat-2.3 {catclose tests} {
- set msgcat [catopen "FOOBAZWAP"]
- catch {catclose -nofail $msgcat}
- } {0}
-
- test message-cat-2.4 {catclose tests} {
- set msgcat [catopen "FOOBAZWAP"]
- catclose $msgcat
- list [catch {catclose -fail $msgcat} msg] $msg
- } {1 {msgcat is not open}}
-
-
- test message-cat-2.5 {catclose tests} {
- list [catch {catclose baz} msg] $msg
- } {1 {invalid msgcat handle: baz}}
-
- test message-cat-2.6 {catclose tests} {
- list [catch {catclose} msg] $msg
- } {1 {catclose [-fail|-nofail] catHandle}}
-
-
- test message-cat-3.1 {catgets tests} {
- set msgcat [catopen "FOOBAZWAP"]
- set msg [catgets $msgcat 1 12 "This is a test"]
- catclose $msgcat
- set msg
- } {This is a test}
-
- test message-cat-3.2 {catgets tests} {
- set msgcat [catopen "FOOBAZWAP"]
- set msg [catgets $msgcat 101 12 "This is an actual emergency"]
- catclose $msgcat
- set msg
- } {This is an actual emergency}
-
- test message-cat-3.3 {catgets tests} {
- set msgcat [catopen "FOOBAZWAP"]
- catclose $msgcat
- list [catch {catgets $msgcat 101 12 "This is an actual emergency"} msg] $msg
- } {1 {msgcat is not open}}
-
- test message-cat-3.4 {catgets tests} {
- set msgcat [catopen "FOOBAZWAP"]
- set out [list [catch {catgets $msgcat xx 12 "This is an actual emergency"} msg] $msg]
- catclose $msgcat
- set out
- } {1 {expected integer but got "xx"}}
-
- test message-cat-3.5 {catgets tests} {
- set msgcat [catopen "FOOBAZWAP"]
- set out [list [catch {catgets $msgcat 102 "This is an actual emergency"} msg] $msg]
- catclose $msgcat
- set out
- } {1 {catgets catHandle setnum msgnum defaultstr}}
-
-